Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically add "restart" commands for language servers #3215

Merged
merged 1 commit into from
Oct 30, 2018

Conversation

simark
Copy link
Contributor

@simark simark commented Oct 18, 2018

It is quite common (though not desirable) to have to restart a language
server, because it misbehaves or doesn't pick up new settings
properly. This patch registers Theia commands for each started language
server.

Change-Id: I567e6e9851ef1b68198d0ac9b25aa9926213d6f9
Signed-off-by: Simon Marchi simon.marchi@ericsson.com

@simark
Copy link
Contributor Author

simark commented Oct 18, 2018

Here's how it looks:

screenshot_2018-10-17_20-18-25

@@ -112,6 +112,10 @@ export abstract class BaseLanguageClientContribution implements LanguageClientCo
}));
}
}, options);

this.registerRestartCommand();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be available only if the server actually running, i.e. like in typescript extension right now.

We also need to remove an existing command from the typescript extension to avoid duplicate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be available only if the server actually running, i.e. like in typescript extension right now.

This is what this code does, doesn't it? activate is only called when starting the language client/server.

We also need to remove an existing command from the typescript extension to avoid duplicate.

Ok.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the language server stops, we should remove the command, but I don't know how to make a language server stop for good.

protected registerRestartCommand(): void {
this.registry.registerCommand({
id: this.restartCommandId(),
label: `Restart ${this.name} language server`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe {this.name}: Restart Server to align with other commands?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I changed it to ${this.name}: Restart Language Server.

@simark simark force-pushed the marie-josee_beland branch from d6f25eb to 82523a0 Compare October 20, 2018 13:58
@simark
Copy link
Contributor Author

simark commented Oct 20, 2018

New version uploaded.

@@ -83,11 +79,6 @@ export class TypeScriptFrontendContribution implements CommandContribution, Menu
isEnabled: () => !!this.clientContribution.logFileUri,
isVisible: () => !!this.clientContribution.logFileUri
});
commands.registerCommand(TypeScriptCommands.restartServer, {
execute: () => this.clientContribution.restart(),
isEnabled: () => this.clientContribution.running,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could implement isEnabled and isVisible in the same way for generic restart command that it is not visible while a server is restarting.

Copy link
Contributor Author

@simark simark Oct 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll do that.

Copy link
Member

@akosyakov akosyakov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tried with TS and JSON, works good

Although the command is visible even when the server is not running, i.e during restart itself, see https://github.com/theia-ide/theia/pull/3215/files#r228837246

It is quite common (though not desirable) to have to restart a language
server, because it misbehaves or doesn't pick up new settings
properly.  This patch registers Theia commands for each started language
server.

Change-Id: I567e6e9851ef1b68198d0ac9b25aa9926213d6f9
Signed-off-by: Simon Marchi <simon.marchi@ericsson.com>
@simark simark force-pushed the marie-josee_beland branch from 82523a0 to 83ac80b Compare October 29, 2018 20:17
@simark
Copy link
Contributor Author

simark commented Oct 29, 2018

Updated. Please merge when you are happy with it (according to @marcdumais-work's interpretation of the Eclipse rules, only committers of the soon-to-be Eclipse project should press the merge button).

@akosyakov akosyakov merged commit 85e3905 into master Oct 30, 2018
@akosyakov akosyakov deleted the marie-josee_beland branch October 30, 2018 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants